<template>
  <div>
    <van-swipe :height="400" @change="onChange">
      <van-swipe-item v-for="item in list" :key="item.pid" v-tap="{methods:detail,id:item.pid}">
        <img :src="item.pimg" alt="第一张" />
        <h4>{{item.pname}}</h4>
        <span>{{item.paddress}}</span>
      </van-swipe-item>
      <div class="custom-indicator" slot="indicator">{{ current + 1 }}/8</div>
    </van-swipe>
  </div>
</template>

<script>
import * as api from "@/api/getProlist.js";
export default {
  name: "MustBuy",
  data() {
    return {
      list: [],
      active: 0,
      current: 0
    };
  },
  mounted() {
    api.getClass({ pclass: 6 }).then(data => {
      this.list = data.data.result;
    });
  },
  methods: {
    onChange(index) {
      this.current = index;
    },
    detail(id){
      this.$router.push("/classdetail?id=" + id.id);
    }
  }
};
</script>

<style scoped>
    .van-swipe-item img{
        width: 100%;
        
    }
</style>